package com.blunka.framework.client.enums;

/**
 * 状态
 * @author Administrator
 *
 */
public enum ModelStatus {
	YES("是",'Y'),NO("否",'N');

	// 成员变量
    private String name;

    private char index;
    // 构造方法
    private ModelStatus(String name, char index) {
        this.name = name;
        this.index = index;
    }
    // 普通方法
    public static String getName(char index) {
        for (ModelStatus c : ModelStatus.values()) {
            if (c.getIndex() == index) {
                return c.name;
            }
        }
        return null;
    }

    public static char getIndex(String name) {
        for (ModelStatus c : ModelStatus.values()) {
            if (c.getName().equals(name)) {
                return c.index;
            }
        }
        return 0;
    }

    /**
     * 根据index获取枚举
     * @param index
     * @return
     */
    public static ModelStatus getEnum(char index){
        for (ModelStatus c : ModelStatus.values()) {
            if (c.getIndex() == index) {
                return c;
            }
        }
        return null;
    }

    public static ModelStatus getEnum(String name){
        for (ModelStatus c : ModelStatus.values()) {
            if (c.getName().equals(name)) {
                return c;
            }
        }
        return null;
    }

    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public char getIndex() {
        return index;
    }
    public void setIndex(char index) {
        this.index = index;
    }

    public String toString(){
    	return this.name();
    }
}
